package com.shenmazong.user.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.core.TopicExchange;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;

/**
 * @author 军哥
 * @version 1.0
 * @description: TODO
 * @date 2022/8/5 14:43
 */

@Configuration
public class RabbitMqConfig {

    @Bean
    public TopicExchange topicExchange() {
        return new TopicExchange("public_message_exchange");
    }

    @Bean
    public Queue loginQueue() {
        return new Queue("public_login_queue");
    }

    @Bean
    public Queue productQueue() {
        return new Queue("public_product_queue");
    }

    @Bean
    public Binding loginToExchange() {
        return BindingBuilder.bind(loginQueue()).to(topicExchange()).with("msg.login");
    }

    @Bean
    public Binding productToExchange() {
        return BindingBuilder.bind(productQueue()).to(topicExchange()).with("msg.product");
    }
}
